//
//  SocketPacket.h
//  Socket.IO-Client
//
//  Created by alanwang.dev on 16/8/8.
//  Copyright © 2016年 com.alanwang.dev. All rights reserved.
//

#import <Foundation/Foundation.h>


typedef NS_ENUM(NSInteger,PacketType) {
  Connect,
  Disconnect,
  Event,
  Ack,
  Error,
  BinaryEvent,
  BinaryAck
};
@interface SocketPacket : NSObject

@property (nonatomic, copy) NSString *nsp;
@property (nonatomic, assign) NSInteger id;
@property (nonatomic, assign) PacketType type;

// getter
@property (nonatomic, strong) NSMutableArray *args;

@property (nonatomic,strong) NSMutableArray<NSData *> *binary;
@property (nonatomic,strong) NSMutableArray *data;
//TODO 重写description方法
@property (nonatomic, copy) NSString *event;

@property (nonatomic, copy) NSString *packetString;

- (instancetype)initWithType:(PacketType)type data:(NSArray *)data id:(NSInteger)id nsp:(NSString *)nsp placeholders:(NSInteger)placeholders binary:(NSArray<NSData *> *)binary;

- (instancetype) initWithType:(PacketType)type nsp:(NSString *)nsp;
- (BOOL)addData:(NSData *)data;

+ (instancetype)packetFromEmit:(NSArray *)items id:(NSInteger)id nsp:(NSString *)nsp ack:(BOOL)ack;

@end
